﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ncp.Business;

namespace ncp.Web.uc
{
    public partial class search : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetHotKeys();
        }

        //获取热门搜索
        private void GetHotKeys()
        {
            var dt = ProductInfoBll.GetHotKeys(CommonConst.DB_Name);
            var builder = new StringBuilder();
            int i = 0;
            foreach (DataRow row in dt.Rows)
            {
                var key = row["Search_Key"];
                var encode = Server.UrlEncode(key.ToString());
                var searchType = row["Search_Type"].ToString();
                if (searchType == "0")
                {
                    builder.AppendFormat("<a href=\"/products/list.html?{0}\">{1}</a>", encode, key);
                }
                else if (searchType == "1")
                {
                    builder.AppendFormat("<a href=\"/buyingleads/index.html?{0}\">{1}</a>", encode, key);
                }
                else if (searchType == "2")
                {
                    builder.AppendFormat("<a href=\"/movement/index.html?{0}\">{1}</a>", encode, key);
                }
                else if (searchType == "3")
                {
                    builder.AppendFormat("<a href=\"/scientific/index.html?{0}\">{1}</a>", encode, key);
                }
                else if (searchType == "4")
                {
                    builder.AppendFormat("<a href=\"/join/index.html?{0}\">{1}</a>", encode, key);
                }
                else
                {
                    builder.AppendFormat("<a href=\"/news/search.html?{0}\">{1}</a>", encode, key);
                }

                if (i == 5)
                {
                    break;
                }
                i++;
            }
            ltHotKey.Text = builder.ToString();
        }
    }
}